<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" scroll="no">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
<link href="${ctx }framework/css/font.css" rel="stylesheet" />
<link href="${ctx }framework/miniui/themes/material/miniui.css" rel="stylesheet" />
<link href="${ctx }framework/css/app.min.1.css" rel="stylesheet" type="text/css" />
<link href="${ctx }framework/css/app.min.2.css" rel="stylesheet" type="text/css" />
<script src="${ctx }framework/main.js" type="text/javascript"></script>
<style type="text/css">
	html, body{margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;} 
</style>
<script>
Page.onLoad(function(){});

function add(){
	mini.open({
		   title:"新建导航菜单",
		   url:"${ctx}eao/setting/menuDialog.jhtml",
		   width:500, 
		   height:380,
		   onOk : function(){save("EaoGrid.saveOneMenu")}
	});
}
function del(){
	var arr2 = mini.get('dg1').getSelectedNode();
	if(arr2.children){
		mini.alert("请先设置子节点");
		return;
	} 
	var arr = mini.get('dg1').getSelectedValue();
	if(!arr ||arr.length==0){
		mini.alert("请先选择要删除的记录！");
		return;
	}
	var dc = {MenuId:arr.join()};
	mini.confirm("确认删除？", function(action){
		if(action == "ok"){
			Server.sendRequest("EaoGrid.delOneMenu",dc,function(response){
				if(response.Status == 1) {
					top.mini.showTips({content:response.Message,state:'success'});
					mini.get('dg1').reload();
				} else {
					mini.alert(response.Message);
				}
			});
		}
	});
}
function edit(e){
	var Id;
	if(e){
		Id=e.row.Id;
	} else {
		var arr = mini.get('dg1').getSelectedValue();
		if(!arr[0]){
			mini.alert("请先选择要编辑的行!");
			return;
		}
		Id=arr[0];
	}
	var option=({
		   title:"查看",
		   url:"${ctx}eao/setting/menuUpdateDialog.jhtml?Id="+Id,
		   width:500,
		   height:280
		});
	option.onOk = function(){save("EaoGrid.saveOneMenu")};
	mini.open(option);
}

function save(method){
	var form = $DW.mini.getForm('form2');
	var dc = form.getData();
	if(form.isValid() == false){
		return;
	}
	 Server.sendRequest(method,dc,function(response){
		if(response.Status == 1) {
			$D.close();
			mini.get('dg1').reload();
			top.mini.showTips({content:response.Message,state:'success'});
		} else {
			mini.alert(response.Message);
		}
	});
}

function setMenuStatus(flag){
	var arr2 = mini.get('dg1').getSelectedNode();
	if(arr2.children){
		mini.alert("请先设置子节点");
		return;
	} 
	var arr = mini.get('dg1').getSelectedValue();
	if(!arr || arr.length == 0){
		mini.alert("请先选择一条记录");
		return;
	}
	var dc = {MenuId:arr.join(),State:flag};
	Server.sendRequest("EaoGrid.setState",dc,function(response){
		if(response.Status == 1) {
			mini.get('dg1').reload();
			top.mini.showTips({content:response.Message,state:'success'});
		} else {
			mini.alert(response.Message);
		}
	});
}

function enable(){
	setMenuStatus(1);
}
function disable(){
	mini.confirm("确认停用？", function(action){
		if(action == "ok"){
			setMenuStatus(0);
		}
	});
}
function action(e) {
	var record = e.record;
	e.cellStyle = "text-align:left";
    return '<a href="javascript:position(\'' + record.MenuId + '\')">权限分配</a>';
   
}
function position(MenuId){
	mini.open({
		width:500,
		height:400,
		title:'权限分配',
		url:'${ctx}eao/setting/positionMenu.jhtml?MenuId=' + MenuId,
		onOk : function(){save("EaoGrid.updatePositionMenu")}
	});
}

function statusRender(e){
	if(e.record.State == '1'){
		return '<i class="iconfont icon-circle-active c-green"></i>';
	} else {
		return '<i class="iconfont icon-ban c-red"></i>';
	}
}

function sort(){
	mini.open({
	   title:"操作帮助排序",
	   url:"${ctx}eao/setting/menuSort.jhtml",
	   width:500,
	   height:400,
	   onOk : function(){
		   $D.close();
			mini.get('dg1').reload();
		},
		onCancel:function(){
			 $D.close();
			mini.get('dg1').reload();
		},
		ondestroy: function (action) { 
			$D.close();
			mini.get('dg1').reload();
	    }
	});
}
</script>
</head>
<body class="body-list">
<div class="mini-toolbar" id="toolbar1">
         <a class="mini-button" iconCls="icon-add" onclick="add();"   plain="true">新建</a>
         <a class="mini-button" iconCls="icon-edit" onClick="edit()"  plain="true">编辑菜单</a>
         <a class="mini-button" iconCls="icon-remove" onClick="del()"  plain="true">删除</a>
         <a class="mini-button" iconCls="icon-sort" onClick="sort()"  plain="true">菜单排序</a>
         <a class="mini-button" iconCls="icon-cricle-active" onClick="enable()"  plain="true">启用</a>
         <a class="mini-button" iconCls="icon-ban" onClick="disable()"   plain="true">停用</a>
</div>
<div class="mini-fit" style="padding:10px;"> 
	<div id="dg1" treeColumn="MenuName" showTreeLines="true" idField="MenuId" iconField="IconCls" parentField="ParentId" class="mini-treegrid z-depth-1" resultAsTree="false" expandOnLoad="0" style="width:100%;height:100%;" showPager="false" method="EaoGrid.findMenu" rowdblclick="edit">
	        <div property="columns">
	        <div type="indexcolumn"></div>
	        <div name="MenuName" field="MenuName" width="100" >菜单名称</div>
	         <div field="State" width="40" renderer="statusRender">启用</div>
	        <div name="Position" field="Position" width="270" >权限</div>
	        <div field="MenuUrl" width="160">URL</div>
	        <div field="CreateTime" dateFormat="yyyy-MM-dd hh:mm:ss" width="160">创建时间</div>
	        <div name="action" renderer="action"  width="7%">操作</div>
	    </div>
	</div>
</div>
</body>
</html>

<!-- Generated by Wisc cost:13ms ip:125.41.184.76 -->